package com.easy.easy.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class LayData {
    private int code=0;
    private String msg="";
    private int count=0;
    private Object data;

    public static LayData error(Exception e){
        return new LayData(500,e.getMessage(),0,null);
    }

    public LayData(int count, Object data) {
        this.count = count;
        this.data = data;
    }

    public LayData() {
    }

    public LayData(int code, String msg, int count, Object data) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }

    public LayData(String imgurl) {
        this.data=new ArrayList();
        HashMap map=new HashMap();
        map.put("src",imgurl);
        ((List)this.data).add(map);
    }

    public static LayData success(){
        return new LayData(0,"操作成功",0,null);
    }

    public static LayData success(String msg){
        return new LayData(0,msg,0,null);
    }
    public static LayData success(Object data){
        return new LayData(0,"操作成功",0,data);
    }
    public static LayData success(String msg,Object data){
        return new LayData(0,msg,0,data);
    }
    public static LayData success(int code,String msg){
        return new LayData(code,msg,0,null);
    }

    public static LayData success(int code,String msg,Object data){
        return new LayData(code,msg,0,data);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
